// 统一管理商品相关接口，主要放了品牌管理相关的接口
import http from '@/utils/http'

// 请求地址
let API = {
  GET_TRADEMARK:'/get_trademark/',
  ADD_TRADEMARK:'/trademark/add/',
  UPDATE_TRADEMARK:'/trademark/update/',
  FILE_UPLOAD:'/trademark/file_upload/',
  DELETE_URL:'/trademark/delete/',
}

// 获取品牌
export const getTrademark = (page,size,category_id) => http.get(`${API.GET_TRADEMARK}${page}/${size}/${category_id}/`)

// 添加与编辑品牌
export const reqAddOrUpdateTrademark = (data)=>{

  if(data.id){
    // 修改已有品牌
    return http.put(API.UPDATE_TRADEMARK,data)
  }else{
    // 添加已有品牌
    return http.post(API.ADD_TRADEMARK,data)
  }

}

// 删除品牌
export const reqDeleteTrademark = (id)=>http.delete(API.DELETE_URL+id+'/')

// 上传品牌logo
export const reqUploadTrademarkLogo = (data,trademarkParams)=>http.post(API.FILE_UPLOAD, data, {
  headers: {
      'Content-Type': 'multipart/form-data'
  },
  params:trademarkParams
})